<template>
	<div>
		<!-- 完成运单提示窗 -->
		<uni-popup ref="completeWaybillDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="确认完成" title="完成运单"
				@confirm="completeWaybillDialogConfirm">
				<scroll-view scroll-top="0" scroll-y="true" style="height: 100px;">
					<view style="display: flex;margin-top: 10px;color: #bf5f09;">
						<text>*确认完成当前运单{{formData.outCode}}*</text>
					</view>
				</scroll-view>
			</uni-popup-dialog>
		</uni-popup>
	</div>
</template>

<script>
	import {
		completeSingleWaybill,
	} from '@/api/system/waybill.js'
	export default {
		props: {
			data: {
				type: Object,
				default: {}
			}
		},
		data() {
			return {
				formData:{
					scheduleNo:''
				},
			}
		},
		watch: {
			data: {
			　　handler(newValue, oldValue) {
			　　　	this.formData=newValue
			　　},
			　　deep: true
			},
		},
		methods: {
			//完成运单
			completeWaybill(){
				this.$refs.completeWaybillDialog.open()
			},
			//确认完成运单
			completeWaybillDialogConfirm(){
				//文件 (回单)
				if(!this.formData.receiptAttachments)
				{
					uni.showToast({
						icon:'none',
						title:'当前运单未上传回单哦~'
					})
					return
				}
				uni.showLoading({
					title: '完成运单...',
				})
				completeSingleWaybill(this.formData.waybillId).then(res => {
					uni.hideLoading()
					if (res.code == '200') {
						uni.showToast({
							title: '此运单成功完成啦！',
							icon: 'success'
						})
						
						this.$parent.init()  //调用父组件的init函数，重新加载数据
						//this.$forceUpdate(); //重新加载数据
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			},
		},
	}
</script>

<style scoped>

</style>